<template>
	<view class="modular">
		<view class="headerBox">
			<view class="header">
				<view class="information">
					<view>
						<view><text>会员</text>：{{userInfo.realName}} </view>
						<view></view>
					</view>
					<view>
						<view><text>性别</text>：{{userInfo.sex && userInfo.sex == 1 ? '男' : '女' || ''}} </view>
						<view><text>年龄</text>：{{userInfo && userInfo.age}}</view>
					</view>
					<view>
						<view><text>评估人</text>：{{detail.appAssessSummaryEntity && detail.appAssessSummaryEntity.userHealthName}}</view>
						<view><text>评估日期</text>：{{detail.appAssessSummaryEntity && detail.appAssessSummaryEntity.assessmentDate}}</view>
					</view>
				</view>
			</view>
			
			<view class="connectBox" v-show="!searchBarFixed">
				<image src="@/static/img/healthStatus/connect@2x.png"></image>
				<image src="@/static/img/healthStatus/connect@2x.png"></image>
			</view>
		</view>
		<view class="mainContent">
			<view v-for="(item,index) in detail.appAssessSummaryDetailEntityList" :key="index">
				<view class="summary" v-if="item.assessmentSn">
					<image :src="'../../static/img/healthStatus/currentSummary/currentSummary'+(item.type)+'@2x.png'" class="topLeft"></image>
					<view class="top">
						<image src="@/static/img/quickly/healthStatus/number@2x.png"></image>
						<view>{{item.assessmentSn}}</view>
						<view>{{item.assessmentDate}}</view>
					</view>
					<view class="bottom">
						<view>{{detail.appAssessSummaryEntity && detail.appAssessSummaryEntity.userName}}</view>
						<view @click="read(item)">详情</view>
					</view>
				</view>
				<view class="noData" v-else>
					<image src="@/static/img/healthStatus/currentSummary/currentSummary2@2x.png" class="topLeft"></image>
					无数据
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {age,distance} from '@/static/js/filter.js'
	export default {
		data () {
			return {
				userInfo: {},
				detail:{},
				searchBarFixed: false
			}
		},
		onPageScroll() {
			this.searchBarFixed = this.distance('mainContent');
		},
		onLoad(option) {
			const _this = this;
			if(option.id) {
				_this.$api.findByUserId(option.userId).then((res)=>{
					_this.userInfo = res.data.result
					_this.userId = option.userId
				})
				_this.$api.appAssessSummaryInfo(option.id).then((res)=>{
					_this.detail = res.data.result
				})
			}
		},
		methods:{
			age,
			distance,
			read(item){
				if(item.type == 2){
					// 体检指标
					uni.navigateTo({url:`/pages/quickly/healthStatus/examined/toView?id=${item.servId}&userId=${this.userId}`})
				}else if(item.type == 3){
					// 生活方式
					uni.navigateTo({url:`/pages/quickly/healthStatus/lifeStyle/toView?id=${item.servId}&userId=${this.userId}`})
				}else if(item.type == 4){
					// 心理评估
					uni.navigateTo({url:`/pages/quickly/psychology/toView?id=${item.servId}&userId=${this.userId}`})
				}else if(item.type == 5){
					// 健康素养
					uni.navigateTo({url:`/pages/quickly/healthStatus/accomplishment/toView?id=${item.servId}&userId=${this.userId}`})
				}else if(item.type == 1){
					// 个人基本信息
					uni.navigateTo({url:`/pages/quickly/information/toView?id=${item.servId}`})
				}else if(item.type == 6){
					// 焦虑
					uni.navigateTo({url:`/pages/quickly/healthStatus/anxious/toView?id=${item.servId}&userId=${this.userId}`})
				}else if(item.type == 7){
					// 抑郁
					uni.navigateTo({url:`/pages/quickly/healthStatus/depressed/toView?id=${item.servId}&userId=${this.userId}`})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import '@/static/css/quickly/healthStatus/toView.scss';
	.summary {
		width: 702upx;
		background: #FFFFFF;
		border-radius: 12upx;
		position: relative;
		padding: 0 28upx 0 42upx;
		box-sizing: border-box;
		margin-bottom: 24upx;
		.topLeft {
			position: absolute;
			left: 0;
			width: 278upx;
			height: 56upx;
			margin-bottom: 32upx;
		}
		.top {
			padding-top: 86upx;
			display: flex;
			position: relative;		
			border-bottom: 1upx solid #cccccc;
			padding-bottom: 24upx;
			image {
				position: absolute;
				left: -48upx;
				top: 61%;
				width: 32upx;
				height: 30upx;
			}
			view {
				flex: 1;
			}
			view:last-child{
				text-align: right;
			}
		}
		.bottom {
			display: flex;
			padding: 25upx 0 35upx;
			view:nth-child(1) {
				flex: 1;
				color: #333333;
				font-size: 40upx;
				font-weight: bold;
			}
			view:last-child {
				width: 146upx;
				height: 50upx;
				background: #6AB7FF;
				border-radius: 25upx;
				color: #FFFFFF;
				font-size: 30upx;
				line-height: 50upx;
				text-align: center;
			}
		}
	}
	.noData {
		width: 702upx;
		height: 96upx;
		background: #FFFFFF;
		border-radius: 12upx;
		position: relative;
		color: #677092;
		font-size: 32upx;
		text-align: right;
		padding-right: 34upx;
		box-sizing: border-box;
		line-height: 96upx;
		margin-bottom: 24upx;
		.topLeft {
			position: absolute;
			left: 0;
			top: 0;
			width: 278upx;
			height: 56upx;
			margin-bottom: 32upx;
		}
	}
</style>
